package messages.data;

import java.util.ArrayList;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class ConversationsPhotographers {
	
	public void runTests() {
		ArrayList<String> webElements = new ArrayList<String>();
		webElements.add("email");
		webElements.add("password");
		conversationTest(webElements);
	}
	
	private void conversationTest(ArrayList<String> webElements) {

		// Photographer:  Zlatan
		WebDriver driver_one = new FirefoxDriver();
		driver_one.get("https://www.snapsation.com/login/");
		WebElement email_one = driver_one.findElement(By.name(webElements.get(0)));
		email_one.sendKeys("damciodamcio666@gmail.com");
		WebElement password_one = driver_one.findElement(By.name(webElements.get(1)));
		password_one.sendKeys("admin123admin");
		email_one.submit();
		WebElement offerPhoto_one = driver_one.findElement(By.xpath("(//ul[@id='offers']/li[2]/div/a/div/div)"));
		offerPhoto_one.click();
		driver_one.get("https://www.snapsation.com/inbox/message/?to=51ac74714c428b421e3c5f92");
		WebElement messagesField = driver_one.findElement(By.xpath("(//form/div/input)"));
		messagesField.sendKeys("Hello Tore Andre Flo. I wont buy your offer");
		messagesField.submit();
		
		// Photographer: Tore
		WebDriver driver_two = new FirefoxDriver();
		driver_two.get("https://www.snapsation.com/login/");
		WebElement email_two = driver_two.findElement(By.name(webElements.get(0)));
		email_two.sendKeys("damczechowski@gmail.com");
		WebElement password_two = driver_two.findElement(By.name(webElements.get(1)));
		password_two.sendKeys("admin123");
		email_two.submit();
		WebElement messagesBox_two = driver_two.findElement(By.xpath("(//div[3]/div[2])"));
		messagesBox_two.click();
		driver_one.get("https://www.snapsation.com/inbox");
		WebElement messages_two = driver_two.findElement(By.xpath("(//ul[@id='inbox']/a/li/div[2]/div)"));
		messages_two.click();
		driver_one.get("https://www.snapsation.com/inbox/message/51bb12ce0e8ef5b242b32806");
		WebElement messagesField_two = driver_two.findElement(By.xpath("(//form/div/input)"));
		messagesField_two.sendKeys("Hello Zlatan. I don't know :) ");
		messagesField_two.submit();
		
		
	}
	
}
